package com.pro.service.imple;

import com.google.gson.Gson;
import com.pro.mapper.JsFeedbackMapper;
import com.pro.pojo.JsUserFeedback;
import com.pro.service.JsFeedbackService;
import com.pro.utils.RedisCache;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName:JsFeedbackServiceImple
 * Package:com.pro.service.imple
 * Description:
 *
 * @Date:2021/11/12 19:18
 * @Author: XJR
 */
@Service
public class JsFeedbackServiceImple implements JsFeedbackService {
    @Autowired
    private JsFeedbackMapper mapper;

    @Autowired
    private RedisCache redisCache;

    private Gson gson = new Gson();

    //查询反馈数据
    public List<JsUserFeedback> selectUserFeedBack(String feedbackType,String feedbackStatus,Integer limit,Integer page){
        page = (page-1)*limit;
        List<JsUserFeedback> jsUserFeedbacks = mapper.selectUserFeedBack(feedbackType, feedbackStatus,limit,page);
        redisCache.setCacheObject("FeedbackSelectUserFeedBack",gson.toJson(jsUserFeedbacks));
        return jsUserFeedbacks;
    };
    public Integer countUserFeedBack(String feedbackType,String feedbackStatus){
        Integer integer = mapper.countUserFeedBack(feedbackType, feedbackStatus);
        redisCache.setCacheObject("FeedbackCountUserFeedBack",integer);
        return integer;
    };

    //通过id查看审核详情
    public JsUserFeedback selectUserFeedBackById(Integer feedbackId){
        JsUserFeedback jsUserFeedback = mapper.selectUserFeedBackById(feedbackId);
        return jsUserFeedback;
    };

    //删除反馈数据
    public Boolean delUserFeedBack(Integer feedbackId){
        Boolean aBoolean = mapper.delUserFeedBack(feedbackId);
        return aBoolean;
    };

    //审核
    public Boolean updateUserFeedStatus(JsUserFeedback jsUserFeedback){
        Boolean aBoolean = mapper.updateUserFeedStatus(jsUserFeedback);
        return aBoolean;
    };

    //查询已受理反馈数据
    public List<JsUserFeedback> selectAdoptUserFeedBack(String feedbackType){
        List<JsUserFeedback> jsUserFeedbacks = mapper.selectAdoptUserFeedBack(feedbackType);
        return jsUserFeedbacks;
    };
    public Integer countAdoptUserFeedBack(String feedbackType){
        Integer integer = mapper.countAdoptUserFeedBack(feedbackType);
        return integer;
    };
}
